<template>
	<!-- 评价 -->
	<view class="container">
		<view class="crad">
			<view class="title">
				已完成
			</view>
			<view class="mid">
				<image :src="info.vehicle_info.type.cover_map" mode=""></image>
				<view class="right">
					<view class="name">
						{{info.vehicle_info.name}}
					</view>
					<view class="load">
						载货吨位:{{info.vehicle_info.type.parameter.tonnage}}
					</view>
					<view class="volume">
						车辆尺寸:{{info.vehicle_info.type.parameter.size}}
					</view>
					<view class="Specifications">
						吊重吨位:{{info.vehicle_info.type.parameter.load}}
					</view>
					<view class="load">
						臂展长度:{{info.vehicle_info.type.parameter.arm_length}}
					</view>
					<view class="load">
						货箱体积:{{info.vehicle_info.type.parameter.container_volume}}
					</view>
					<view class="load">
						载货空间:{{info.vehicle_info.type.parameter.cargo_space}}
					</view>
					<view class="load">
						应用场景介绍:{{info.vehicle_info.type.parameter.introduce}}
					</view>
				</view>
			</view>
			<view class="btns">
				<!-- <view class="delete">
					删除订单
				</view> -->
				<view class="details" @tap="goComplete(info)">
					订单详情
				</view>
			</view>
		</view>
		<view class="rate">
			<uni-rate :value="strat" size="35"></uni-rate>
			<view class="title">
				评价
			</view>
			<textarea v-model="content" placeholder="输入评价" />
			<view class="btn" @tap="tijiao">
				提交
			</view>
		</view>
	</view>
</template>

<script>
	import uniRate from '@/components/uni-rate/uni-rate.vue'
	export default {
		components:{
			uniRate
		},
		data() {
			return {
				strat:5,
				token:'',
				id:'',
				info:'',
				content:'',
				imgUrl:''
			};
		},
		onLoad(e) {
			// console.log(e)
			// console.log(JSON.parse(e.info))
			this.token=e.token
			this.id=JSON.parse(e.info).id
			this.info=JSON.parse(e.info)
			this.imgUrl=this.webUrl
		},
		methods:{
			goComplete(info){
				// console.log(info)
				uni.navigateTo({
					url: '../complete/complete?id='+info.id+'&token='+this.token,
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			},
			tijiao(){
				if(this.content==''){
					uni.showToast({
						title: '请填写评论内容',
						icon:'none',
						duration:2000
					});
				}else{
					uni.showLoading({
						title: '加载中',
						mask: false
					});
					uni.request({
						url: this.webUrl+'/user/job/comment/'+this.id,
						method: 'POST',
						header:{
							token:this.token
						},
						data: {
							rate:this.strat,
							content:this.content
						},
						success: res => {
							console.log(res)
							uni.hideLoading()
							if(res.data.code==0){
								uni.showToast({
									title: '评价成功',
									icon:'none',
									duration:2000
								});
								setTimeout(()=>{
									uni.navigateBack({
										delta: 1
									});
								},1500)
							}else if(res.data.code==3){
								uni.showToast({
									title: res.data.msg,
									icon:'none',
									duration:2000
								});
							}else{
								uni.showToast({
									title: '网络错误',
									icon:'none',
									duration:2000
								});
							}
						},
						fail: () => {
							uni.showToast({
								title: '网络错误',
								icon:'none',
								duration:2000
							});
						},
						complete: () => {}
					});
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container{
		position: absolute;
		bottom: 0;
		left: 0;
		right: 0;
		top: 0;
		background: #F2F2F2;
		.crad{
			overflow: hidden;
			margin: 30upx auto 0;
			width:690upx;
			// height:316upx;
			padding-bottom: 20upx;
			background:rgba(255,255,255,1);
			box-shadow:0upx 3upx 15upx 1upx rgba(0, 0, 0, 0.11);
			border-radius:30upx;
			.title{
				font-size:30upx;
				line-height: 30upx;
				margin: 30upx 0 0 24upx;
				font-family:Microsoft YaHei;
				font-weight:400;
				color:rgba(254,86,33,1);
			}
			.mid{
				display: flex;
				// margin-top: 20upx;
				image{
					margin-left: 38upx;
					width: 180upx;
					height: 180upx;
				}
				.right{
					margin-left: 60upx;
					font-size:22upx;
					font-family:Microsoft YaHei;
					font-weight:400;
					color:rgba(52,52,52,1);
					.name{
						// margin-bottom: 30upx;
						line-height: 22upx;
					}
					.item{
						line-height: 34upx;
					}
				}
			}
			.btns{
				display: flex;
				font-size:24upx;
				font-family:Microsoft YaHei;
				font-weight:400;
				margin-left: 416upx;
				color:rgba(255,254,254,1);
				.delete,.details{
					width:120upx;
					height:40upx;
					background:rgba(254,86,33,1);
					border-radius:20upx;
					text-align: center;
					line-height: 40upx;
				}
				.delete{
					margin-right: 18upx;
				}
			}
		}
		.rate{
			background: #FFFFFF;
			padding: 50upx 30upx 160upx;
			margin-top: 30upx;
			.uni-rate{
				display: flex;
				justify-content: space-between;
			}
			.title{
				margin-top: 36upx;
				font-size:36upx;
				font-family:Microsoft YaHei;
				font-weight:bold;
				color:rgba(51,51,51,1);
			}
			textarea{
				margin-top: 34upx;
				padding: 26upx;
				width:638upx;
				height:348upx;
				border:2upx solid rgba(0,0,0,1);
				border-radius:30upx;
				font-size:28upx;
				font-family:Microsoft YaHei;
				font-weight:400;
				color:rgba(51,51,51,1);
			}
			.btn{
				margin: 36upx auto 0;
				text-align: center;
				line-height: 80upx;
				font-size:28upx;
				font-family:Microsoft YaHei;
				font-weight:400;
				color:rgba(255,255,255,1);
				width:200upx;
				height:80upx;
				background:rgba(254,86,33,1);
				border-radius:10upx;
			}
		}
	}
</style>
